package ngamejava2;

public class GameRenderer implements Runnable
{
	private boolean terminated;
	private long currentFrame;
	private iGameLoopListener renderListener;

	public GameRenderer(iGameLoopListener aRenderListener)
	{
		setRenderable(aRenderListener);
	}

	public GameRenderer()
	{
		this(null);
	}

	public void run()
	{
		currentFrame = 0;
		terminated = false;
		while (!terminated)
		{
			if (renderListener != null)
			{
				renderListener.gameLoopRender(currentFrame++);
			}
			Thread.yield();
		}
	}

	public void setRenderable(iGameLoopListener aRenderListener)
	{
		renderListener = aRenderListener;
	}

	public void terminate()
	{
		terminated = true;
	}
}
